def test():
    import random
    from psim import PSim
    
    p = 2
    ps = PSim(p)
    comm = ps.getComm()
    a=sum(comm.all2all_broadcast(comm.rank))
    comm.barrier()
    b=comm.all2all_reduce(comm.rank)
    result = sum([i for i in range(p)])
    if a!=result or a!=b:
        print 'from process', comm.rank
        raise Exception
    if comm.rank==0: print 'test passed'
    
if __name__=='__main__': 
    test()

